/**
 * 注册新用户�����û�
 */
Divo.app.register = function() {
	/* ----------------------- private属性 ----------------------- */
	var tn = 1;
	var fldUserName, fldPassword, fldPassword2, fldRealName;
	var oStatusBar;

	/* ----------------------- private方法 ----------------------- */
	// 创建表单
	function createForm() {
		fldUserName = new Ext.form.TextField( {
			tabIndex : tn++,
			applyTo : 'register-username'
		});
		fldRealName = new Ext.form.TextField( {
			tabIndex : tn++,
			applyTo : 'register-name'
		});
		fldPassword = new Ext.form.TextField( {
			tabIndex : tn++,
			inputType : 'password',
			applyTo : 'register-password'
		});
		fldPassword2 = new Ext.form.TextField( {
			tabIndex : tn++,
			inputType : 'password',
			applyTo : 'register-verify'
		});
	}

	// 提交
	function onSubmit() {
		var userName = fldUserName.getValue();
		var realName = fldRealName.getValue();
		var pswd = fldPassword.getValue();
		var pswd2 = fldPassword2.getValue();
		
		var onRegister = function(retValue) {
			if (retValue) {
				Divo.say("保存成功");
				goHome();
				return;
			}	
			Divo.error("保存失败");
		}
		
		Divo.wait("正在保存...");
		Divo.rmtCallAsync("sampleFacade.register",onRegister,[userName,realName,pswd,pswd2]);
	}

	//取消
	function onCancel() {
		goHome();
	}
	
	//跳转到HOME
	function goHome() {
		window.location = Divo.getFullPath()+"app/home.seam";
	}
	
	/* ----------------------- public方法 ----------------------- */
	return {

		//初始化�
		init : function() {
			oStatusBar = Divo.app.StatusBar;
			oStatusBar.init();

			createForm();

			Ext.get('register-ok').on('click', function() {
				onSubmit();
			});

			Ext.get('register-cancel').on('click', function() {
				onCancel();
			});

			Divo.endLoading();
		}

	}; // return

}();

Ext.onReady(Divo.app.register.init, Divo.app.register, true);

// EOP

